package com.hd.base.service;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.hd.base.dao.BaseMapper;


@Service("baseService")
public abstract class BaseService<T> {

	public abstract BaseMapper<T> getMapper();

	public void save(T model) {
		System.out.println("----------model-------model----" + model);
		getMapper().save(model);
	}

	public void save(List<T> models) {
		getMapper().save(models);
	}

	public void update(T model) {
		getMapper().update(model);
	}

	public void deleteById(String id) {
		getMapper().deleteById(id);
	}

	public void deleteByCondition(T model) {
		getMapper().deleteByCondition(model);
	}

	public void deleteByIds(String ids) {

		if (StringUtils.isNotEmpty(ids)) {
			String[] idList = ids.split(",");
			for (String id : idList) {
				this.deleteById(id);
			}
		}

	}

	public T queryById(String id) {
		return getMapper().queryById(id);
	}

	public List<T> queryByList() {
		return getMapper().queryByList();
	}

	public List<T> findByCondition(T model) {
		return getMapper().findByCondition(model);
	}

	public int queryCount(T model) {
		return getMapper().queryCount(model);
	}

	public int queryCountByCondition(Object condition) {
		return getMapper().queryCountByCondition(condition);
	}

}
